﻿using System;
using System.Linq;
using NUnit.Framework;
using ProjetoComperio.BusinessLogicLayer;
using ProjetoComperio.DataLayer.Entities;
using ProjetoComperio.Presentation.Web.Controllers;
using ProjetoComperio.Test.WebUI.FakeObjects;

namespace ProjetoComperio.Test.WebUI.Controllers
{
    [TestFixture]
    public class StudentControllerTest
    {
        //FormCollection formCollection;

        private StudentController studentController;
        StudentBLL studentBLL;
        [SetUp]
        public void SetUp()
        {
            studentBLL = new StudentBLL();
            studentController = new StudentController();
            studentController.ControllerContext = new FakeControllerContext(studentController);

        }

        [Ignore]
        public void TestValidateFormInvalidFormCollection()
        {
        }

        [Test]
        public void TestValidCreate()
        {
            Student student = FillValidStudent();
            studentController.Create(student);
            Assert.IsTrue(studentBLL.RetrieveStudents().Any(x => x.Name.Equals(student.Name)));
        }

        private Student FillValidStudent()
        {
            Student student = new Student();
            var currentDateTime = DateTime.Now;

            student.Name = "Higor Ramos" + currentDateTime.ToString();
            student.Email = "Higor@mail.com" + currentDateTime.ToString();
            student.BirthDate = currentDateTime;
            student.EducationLevelID = 1;
            student.Street = "Rua abcd";
            student.Neighbourhood = "Centro";
            student.ZipCode = "21223456";
            student.AddressNumber = "120";
            student.Country = "Brasil";
            student.City = "Rio de Janeiro";
            student.State = "RJ";
            student.Enrollment = currentDateTime.ToString();
            student.LattesPlatformWebPage = "LattesPlatformWebPage" + currentDateTime.ToString();
            student.AcademicOrganizationID = 1;
            student.StartDate = currentDateTime.AddYears(-2);
            student.CourseID = 1;

            return student;
        }

    }
}
